<div class="cont" style="overflow:hidden;">
    <div class="position">
        <img alt="位置图标" src="dist/images/position.png" />系统管理&gt;部门管理
    </div>
    <div class="mybackground" style="overflow:hidden;">
        <div class="cont_fr_top">
            <div class="menus_top">
                <div class="menus_l">部门管理(点击节点进行编辑)</div>
                <div class="cont_fr_btn">
                    <div class="fr">
                        <button class="cont_f_btn3" ng-click="nodeAdd()" >添加部门</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="menus">
        <div class="ui grid row" style="margin-top:1.2em;margin-left:0.33em;">
            <div class="ui big list" list-tree tree-nodes="treeSectors"  edit-fn="nodeEdit"   efn="nodeEdit" node-id="sector_id" node-children="_child" node-label='sector_name' id="lt"></div>
        </div>
    </div>
</div>
<!-- 添加弹窗开始 -->
<div class="ui sector add small modal">
    <i class="close icon"></i>
    <div class="header_h4">
        添加部门
    </div>
    <div class="content">
        <form action="#" name="frm-add" id="frm-add" style="width:94%;margin-left:3%;">
            <div class="ui form">
                <div class="inline field required">
                    <label class="two wide field">部门名称</label>
                    <input type="text" name="sector_name" ng-model="add_data.sector_name" placeholder="请输入新增部门名称">
                </div>
                <div class="inline field required">
                    <label class="two wide field">上级部门</label>
                    <select class="ui dropdown selection add_sector" ng-model="add_data.parent_sector">
                        <option value="" >默认为你的部门</option>
                        <option value="{{vitem.sector_id}}"
                                    ng-repeat="vitem in treeSectors|tree2Arr:'_child'" >
                                    {{vitem.rep}}{{vitem.sector_name}}
                        </option>
                    </select>
                </div>
                <div class="inline field">
                    <label class="two wide field">部门负责人</label>
                    <select class="ui search selection dropdown" ng-model="add_data.manager_id" >
                        <option value="">请选择部门负责人</option>
                        <option value="{{option.user_id}}"  ng-repeat="option in users">{{option.nickname }}</option>
                    </select>
                </div>
                <div class="inline field">
                    <label class="two wide field">部门备注信息</label>
                    <input type="text" name="info" ng-model="add_data.info" class="seven wide field" placeholder="部门信息备注">
                </div>
            </div>
        </form>
    </div>
    <div class="actions ">
        <button class="ui green button positive">{{'BTN_OK' | translate}}</button>
        <button class="ui grey button negative">{{'BTN_CANCEL' | translate}}</button>
    </div>
</div>
<!-- //添加弹窗结束-->

<!-- 编辑弹窗开始 -->
<div class="ui sector edit small modal">
    <i class="close icon"></i>
    <div class="header_h4">
        修改部门信息
    </div>
    <div class="content">
        <form action="#" name="frm-edit" id="frm-edit" style="width:94%;margin-left:3%;">
            <input type="hidden" name="sector_id" value="{{edit_data.sector_id}}">
            <div class="ui form">
                <div class="inline field required">
                    <label class="two wide field">部门名称</label>
                    <input type="text" name="sector_name" placeholder="请输入新增部门名称" value="{{edit_data.sector_name}}">
                </div>
                <div class="inline field required">
                    <label class="two wide field">上级部门</label>
                    <select class="ui dropdown edit_sector" ng-model="edit_data.parent_sector">
                        <option value="" >默认为你的部门</option>
                        <option value="{{vitem.sector_id}}"
                                    ng-repeat="vitem in treeSectors|tree2Arr:'_child'"
                                    ng-selected="edit_data.parent_sector == vitem.sector_id"  >
                                    {{vitem.rep}}{{vitem.sector_name}}
                        </option>
                    </select>
                </div>
                <div class="inline field">
                    <label class="two wide field">部门负责人</label>
                    <select class="ui search dropdown edit_sector" ng-model="edit_data.manager_id"  >
                        <option value="">请选择部门负责人</option>
                        <option value="{{option.user_id}}" ng-value="option.user_id" ng-repeat="option in users"
                                    ng-selected="edit_data.manager_id == option.user_id" >
                                        {{option.nickname }}
                        </option>
                    </select>
                </div>
                <div class="inline field">
                    <label class="two wide field">部门备注信息</label>
                    <input type="text" ng-model="edit_data.info" class="seven wide field"   placeholder="部门信息备注">
                </div>

            </div>
        </form>
    </div>
    <div class="actions ">
        <button class="ui green button positive">{{'BTN_OK' | translate}}</button>
        <button class="ui grey button negative">{{'BTN_CANCEL' | translate}}</button>
    </div>
</div>
<!-- //编辑弹窗结束 -->
<script type="text/javascript">
    $(function(){
        //$('.ui.dropdown').dropdown();
        $('.ui.dropdown').dropdown({
            message:{noResults:'负责人查询结果为空'},
            allowReselection:true
        });
        $('#frm-add').form({
            inline:true,
            on: 'blur',
            fields: {
                sector_name: {
                identifier: 'sector_name',
                rules: [
                    {
                    type   : 'empty',
                    prompt : '新增部门名称不能为空'
                    }
                ]},
                parent_sector:{
                identifier: 'parent_sector',
                rules: [
                    {
                    type:'empty',
                    prompt:'上级部门不能为空'
                    }
                ]},
            }});
        $('#frm-edit').form({
            inline:true,
            on: 'blur',
            fields: {
                sector_name: {
                identifier: 'sector_name',
                rules: [
                    {
                    type   : 'empty',
                    prompt : '部门名称不能为空'
                    }
                ]},
                parent_sector:{
                identifier: 'parent_sector',
                rules: [
                    {
                    type:'empty',
                    prompt:'上级部门不能为空'
                    }
                ]},
            }});
        });
</script>